#include<bits/stdc++.h>
using namespace std;

int a[100010];

int main()
{
	int n, m, k;
	cin>>n;
	for(int i = 1;i <= n;i++)
		cin>>a[i];
	cin>>m;
	while(m--)
	{
		cin>>k;
		int index = lower_bound(a+1, a+n+1, k)-a;
		if(index > n)
			cout<<a[n]<<endl;
		else
		{
			if(index == 1)
				cout<<a[1]<<endl;
			else if(a[index]-k < k-a[index-1])
				cout<<a[index]<<endl;
			else
				cout<<a[index-1]<<endl;
		}
	}
	cout<<endl;
	system("pause");
	return 0;
}

